1. Field of the Invention
The present invention relates generally to computer security and, more particularly, to a method and apparatus of encrypting keystrokes, entered on a computer keyboard, before they are processed by a browser so that resident keyloggers cannot capture them.
2. Description of the Related Art
What is a Keylogger?
A Keylogger is a software program that runs in the background, recording all the keystrokes. Once keystrokes are logged, they are hidden in the machine for later retrieval, or shipped raw to the attacker. The attacker then peruses them carefully in the hopes of either finding passwords, or possibly other useful information such as credit card numbers, social security numbers or any other information used to commit identity theft.
A keyloggers can enter a user's computer in the following ways—(1) They can be embedded in images and music files which the user downloads when they click on pictures or mp3 files. (2) They can be downloaded inadvertently when a user browses a malicious web site. (3) They can be embedded in a virus, spyware or Trojan horse. (4) They can be bundled as a part of software that a user downloads for free.
How Keyloggers Work
When a user presses a key on the keyboard, the keyboard device driver receives scan codes from the keyboard, which are sent to the keyboard layout where they are translated into messages and posted to the appropriate window in the application. Assigned to each key on a keyboard is a unique value called a scan code, a device-dependent identifier for the key on the keyboard. A keyboard generates two scan codes when the user types a key—one when the user presses the key and another when the user releases the key.
The keyboard device driver interprets a scan code and translates it to a virtual-key code, a device-independent value defined by the system that identifies the purpose of a key. After translating a scan code, the keyboard driver creates a message that includes the scan code, the virtual-key code, and other information about the keystroke, and then places the message in the system message queue. The system removes the message from the system message queue and posts it to the message queue of the appropriate thread of the application. Eventually, the thread's message loop removes the message and passes it to the appropriate window procedure of the application for processing.
A keylogger can intercept the keystroke at any point in the chain. It can intercept it in any of following ways—(1) the keyboard driver level—by replacing the keyboard driver with a rogue driver, (2) by adding filters between the keyboard driver and the system message queue. The filter receives keystrokes from the keyboard driver before it is sent to the message queue. and (3) the system message queue level—by hooking into the Windows message queue. A hook is a callback function provided by the keylogger to the system. When a keystroke message arrives in the message queue, the callback function associated with the keylogger is called and it is passed the keystroke information. The keylogger then stores the keystroke data in a file which is later sent to the hacker via an email, an IRC channel or some other means.
Current State-of-the Art in Anti-Keylogging
Currently, there are two ways to stopping keyloggers—(1) detecting them and (2) preventing them from hooking the keystroke messages.
Keyloggers can be detected by analyzing their signatures. Signatures comprise the characteristics of the keylogger such as file size, file name, a checksum, or registry entries. The drawback of this method is that the signatures need to be constantly updated and is not effective against unknown keyloggers.
Keyloggers can be prevented from hooking the keystroke messages by placing a hook before the keylogger's hook and preventing the keystroke messages from going to the keylogger. The drawback of this method is that there is no way to guarantee that a hook can be placed before the keylogger's hook.